<?xml version="1.0" encoding="utf-8"?>
<Content xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:blueonionsoftware-com:bloget:runtime:data">
  <text>Performance monitor is part of the OS and provides *much* better resource usage monitoring than Task Manager.  You can run it from the command line as:  perfmon.msc

Another reason to use perfmon instead is, Task Manager's concept of  "mem usage", as seen on the graphical view, changes with each release of Windows.

So what is Mem Usage:

Working Set = RAM usage.  The perfmon counter is Process -&gt; Working Set.  For Task Manager, you can add a column called Mem Usage on the Processes tab view.

Committed Bytes = more or less what you think of as virtual memory usage = RAM + pagefile usage.  The perfmon counter is Process -&gt; Private Bytes.  The Task Manager column is called VM Size.

Virtual Address Space (VAS) = the real virtual memory usage = Committed Bytes + Reserved Bytes + leftover bytes.  The perfmon counter is Process -&gt; Virtual Bytes.  Task Manager doesn't have a column for a process' VAS.  Reserved bytes can be allocated directly from ::VirtualAlloc, and I suspect, indirectly from ::HeapCreate and thread creation.  Note that the CLR is itself all Win32 user code (just like any other Win32 application).  Ultimately the GC will use one or both of these API functions to allocate memory, and thus will have its own use of committed and reserved bytes.  The leftover bytes mentioned above come from the fact that ::VirtualAlloc only allocates on a minimum region size of 64kB.

VAS also imposes the hard limit of 2GB / process in the Win32 operation system.  So even if you have 6GB RAM installed, or 20GB of pagefile.sys size, each process is allowed to use up to 2GB of Virtual Address Space in total.  In practice, a process' Virtual Address Space used is quite a bit larger than the Committed Bytes.  Also, your process will crash as the total VAS used gets close to 2GB, in practice more like 1.8 or 1.9GB, even though you will have significantly less Committed Bytes used.

&lt;img src='http://aabmag23a/devnotes/wp-content/perfmonscreen.png' alt='' /&gt;

In this screenshot, rsntmain has 696,786,944 bytes of total VAS used, and 176,480,244 for # Total reserved Bytes (managed reserved Bytes), therefore 696,786,944 - 176,480,244 = 520,306,700 reserved Bytes used by unmanaged code.  Also, rsntmain has 370,155,520 Private Bytes used total, with 162,742,260 for # Total committed bytes for managed code, which leaves 207,413,260 committed bytes used by unmanaged code.

Nice description of Virtual Address Space:
&lt;a href="http://blogs.msdn.com/slavao/archive/2005/01/27/361678.aspx"&gt;http://blogs.msdn.com/slavao/archive/2005/01/27/361678.aspx&lt;/a&gt;</text>
  <last_update>2007-10-04T00:52:37.2460806Z</last_update>
  <source_title />
  <source_link />
  <comments />
  <references />
  <attachments />
</Content>